package com.bailian.snails.controller;

import com.bailian.snails.feigin.UserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author gaoxu
 * date: Created on 2021/5/31 下午1:45
 */

@RestController
@RequestMapping("/order")
public class OrderController {

//    @Autowired
//    private RestTemplate restTemplate;

    @Autowired
    private UserClient userClient;

//    @RequestMapping(value = "/findOrderByUserId/{id}", method = RequestMethod.GET)
//    public String findOrderByUserId(@PathVariable("id") String id) {
//        /**
//         * 1.更改成服务名称调用
//         * 2.选择一个负载均衡器,去调用服务snails-mall-hello服务 && 选择一个去调用
//         * 3.restTemplate 扩展点, ClientHttpRequestInterceptor
//         * 4.ribbon LoadBalancerInterceptor负载均衡器  LoadBalancerInterceptor implements ClientHttpRequestInterceptor
//         *   ->
//         */
//        String urlpath = "http://snails-mall-hello/snails-mall-hello/test";
//        String result = restTemplate.getForObject(urlpath, String.class);
//        return result;
//    }


    @RequestMapping(value = "/findOrderByUserId2/{id}", method = RequestMethod.GET)
    public String findOrderByUserId2(@PathVariable("id") String id) {
        String orderByUserId = userClient.findOrderByUserId(id);
        return orderByUserId;
    }
}